package com.job.meeting.service.impl;

import com.job.meeting.mapper.UserMapper;
import com.job.meeting.pojo.booking;
import com.job.meeting.pojo.user;
import com.job.meeting.service.userService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userService")

public class userServiceImpl implements userService {
    @Autowired
    UserMapper userMapper;
    //更新用户信息，返回是否成功
    //成功返回值等于1，失败等于0
    @Override
    public int updateUser(user user) {
        return userMapper.updateUser(user);
    }
    //这个函数负责插入user，返回是否成功。
    //如果当前数据库有这个user，返回失败——这也许意味着你可能需要使用对应的update函数。
    //成功返回值等于1，失败等于0
    @Override
    public int insertUser(user user) {
        return userMapper.insertUser(user);
    }
    //输入用户权力，返回拥有对应权力的全部user
    //0是普通用户，1是管理员
    @Override
    public List<user> getUserByPrivileges(int privilege) {
        return userMapper.getUserByPrivileges(privilege);
    }
    //根据传入的openID判断是不是管理员。是则为True,否则false
    @Override
    public boolean PrivilegesVerification(String openID) {
        int userPrivilege = userMapper.PrivilegesVerification(openID);
        return (userPrivilege == 1);
    }

    @Override
    public user getUserByOpenid(String openid) {
        return userMapper.getUserByOpenid(openid);
    }

    @Override
    public user getUserByUserId(int id) {
        return userMapper.getUserByUserId(id);
    }

}
